<?php
    session_start();
    if(!isset($_SESSION['username'])){
                header("Location: index.php");
                $_SESSION['log']=1;
    }
    else{
?>
        <form action="updatePrice.php" method="POST">

        <?php
            $products;
            $multicall=array();
            $j=0;
            foreach($_SESSION['stored_prod'] as $p){
                $multicall[$j]=array('catalog_product.info',array($p['sku'], $_SESSION['username']));
                $j++;
            }
            try{
                include 'config.php';
                $proxy = new SoapClient($config['SOAPLocation']);
                $sessionId = $proxy->login($config['SOAPUser'],$config['SOAPKey']);
                $products = $proxy->multiCall($sessionId, $multicall);
                $proxy->endSession($sessionId);
            }
            catch(Exception $e){
                echo $e;
            }
            $i=0;
            foreach($products as $p){
                echo $p['name']."--";
                echo $p['sku'];
                echo "<input type='hidden' name='sku_$i' value='{$p['sku']}' />";
                echo "----Price: <input type='text' name='price_$i' value='{$p['price']}' />";
                $check='';
                foreach($p['websites'] as $w){
                    if($w == $_SESSION['code']){
                        $check='checked="checked"';
                    }
                }
                echo "Include this item in store <input type='checkbox' name='add_$i' value='yes' $check /><br>";
                $i++;
            }
            $_SESSION['stored_prod']=$products;
            echo '<input type="submit" value="Submit" name="price_send" />';
        ?>
        </form>
<?php } ?>
